﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Microsoft.VisualBasic;

namespace SalePartial.Model
{

    public class XPDeliveryAddresInfo
    {
        // Methods
        public XPDeliveryAddresInfo()
        {
            this._companyID = Guid.Empty;
            this._contact = string.Empty;
            this._street = string.Empty;
            this._city = string.Empty;
            this._province = string.Empty;
            this._country = string.Empty;
            this._postcode = string.Empty;
            this._phone = string.Empty;
            this._cellPhone = string.Empty;
        }

        public XPDeliveryAddresInfo(SqlDataReader reader)
        {
            this._companyID = Guid.Empty;
            this._contact = string.Empty;
            this._street = string.Empty;
            this._city = string.Empty;
            this._province = string.Empty;
            this._country = string.Empty;
            this._postcode = string.Empty;
            this._phone = string.Empty;
            this._cellPhone = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPDeliveryAddresInfo(Guid id)
        //{
        //    this._companyID = Guid.Empty;
        //    this._contact = string.Empty;
        //    this._street = string.Empty;
        //    this._city = string.Empty;
        //    this._province = string.Empty;
        //    this._country = string.Empty;
        //    this._postcode = string.Empty;
        //    this._phone = string.Empty;
        //    this._cellPhone = string.Empty;
        //    SqlDataReader reader = XPDeliveryAddresUtility.SelectReader(id);
        //    if (reader.Read())
        //    {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    }
        //    else
        //    {
        //        if (!reader.IsClosed)
        //        {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPDeliveryAddress does not exist.");
        //    }
        //}

        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._addressID = reader.GetGuid(0);
                this._companyID = reader.GetGuid(1);
                if (!reader.IsDBNull(2))
                {
                    this._contact = reader.GetString(2);
                }
                if (!reader.IsDBNull(3))
                {
                    this._street = reader.GetString(3);
                }
                if (!reader.IsDBNull(4))
                {
                    this._city = reader.GetString(4);
                }
                if (!reader.IsDBNull(5))
                {
                    this._province = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    this._country = reader.GetString(6);
                }
                if (!reader.IsDBNull(7))
                {
                    this._postcode = reader.GetString(7);
                }
                if (!reader.IsDBNull(8))
                {
                    this._phone = reader.GetString(8);
                }
                if (!reader.IsDBNull(9))
                {
                    this._cellPhone = reader.GetString(9);
                }
                this._isDefault = reader.GetBoolean(10);
                this._createDate = reader.GetDateTime(11);
            }
        }

        // Properties
        public Guid AddressID
        {
            get { return this._addressID; }
            set { this._addressID = value; }
        }

        public string CellPhone
        {
            get { return this._cellPhone; }
            set { this._cellPhone = value; }
        }

        public string City
        {
            get { return this._city; }
            set { this._city = value; }
        }

        public Guid CompanyID
        {
            get { return this._companyID; }
            set { this._companyID = value; }
        }

        public string Contact
        {
            get { return this._contact; }
            set { this._contact = value; }
        }

        public string Country
        {
            get { return this._country; }
            set { this._country = value; }
        }

        public DateTime CreateDate
        {
            get { return this._createDate; }
            set { this._createDate = value; }
        }

        public bool IsDefault
        {
            get { return this._isDefault; }
            set { this._isDefault = value; }
        }

        public string Phone
        {
            get { return this._phone; }
            set { this._phone = value; }
        }

        public string Postcode
        {
            get { return this._postcode; }
            set { this._postcode = value; }
        }

        public string Province
        {
            get { return this._province; }
            set { this._province = value; }
        }

        public string Street
        {
            get { return this._street; }
            set { this._street = value; }
        }


        // Fields
        private Guid _addressID;
        private string _cellPhone;
        private string _city;
        private Guid _companyID;
        private string _contact;
        private string _country;
        private DateTime _createDate;
        private bool _isDefault;
        private string _phone;
        private string _postcode;
        private string _province;
        private string _street;
    }


}
